package com.th.cash.th2.main

import com.th.basemodel.base.BaseRepository
import com.th.basemodel.bean.OkResult
import com.th.basemodel.ext.extRequestHttp
import com.th.cash.http.AppRetrofit
import com.th.cash.th2.product.OrderUrlRequest
import com.th.cash.th2.product.OrderUrlResponse
import com.th.cash.th2.product.ProductDetailRequest
import com.th.cash.th2.product.ProductDetailResponse

class MainRepository : BaseRepository() {

    suspend fun getHome(): OkResult<HomeResponse> {
        return extRequestHttp {
            AppRetrofit.mainService.getHome()
        }
    }

    suspend fun getUserCenter(): OkResult<UserCenterResponse> {
        return extRequestHttp {
            AppRetrofit.mainService.getUserCenter()
        }
    }

    suspend fun getOrders(request: OrderRequest): OkResult<OrderResponse> {
        return extRequestHttp {
            AppRetrofit.mainService.getOrders(request)
        }
    }

    suspend fun applyProduct(request: ProductApplyRequest): OkResult<ProductApplyResponse> {
        return extRequestHttp {
            AppRetrofit.mainService.applyProduct(request)
        }
    }

    suspend fun getProductDetail(request: ProductDetailRequest): OkResult<ProductDetailResponse> {
        return extRequestHttp {
            AppRetrofit.mainService.getProductDetail(request)
        }
    }

    suspend fun getOrderUrl(request: OrderUrlRequest): OkResult<OrderUrlResponse> {
        return extRequestHttp {
            AppRetrofit.mainService.getOrderUrl(request)
        }
    }
}